<%@page language="java" pageEncoding="UTF-8"%>
<%@page import="org.firecloud.h5fun.model.CommonConfig"%>
<%@page import="org.firecloud.h5fun.model.javabean.*"%>
<%
	CommonConfig webconfig = (CommonConfig) request.getServletContext().getAttribute("commonConfig");
	ProjectBean project = (ProjectBean) request.getAttribute("project");
	ApplicationBean app = (ApplicationBean) request.getAttribute("application");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/common.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/page-show-application.js"></script>
<title><%=webconfig.getTitle()%></title>
<script type="text/javascript">
	var page = 0;
	$(document).ready(function() {
		function loadCommentarys(page){
			var appId = <%=app.getId()%>;
			$.post('ajax_get_commentarys',{'appId':appId,'page':page},function(data,status){
				if (status == 'success') {
					if(data.type==0){
						for(var i in data.datas){
							$('#commentarys').append('<div class="commentary-cell">'+data.datas[i].context+'<div class="commentary-cell-info">'+'<a href="ShowUserInfo?id='+data.datas[i].userId+'"><i class="icon-user"></i>'+data.datas[i].userName+'</a>'+'发表于'+data.datas[i].date+'</div>'+'</div>');
						}
					}
				}
			});
		}
		
		$('#loadMoreCommentarys').click(function(){
			page++;
			loadCommentarys(page);
		});
		$('#commentary-send').click(function() {
			var appId = <%=app.getId()%>;
			$.post('ajax_create_commentary', {
				'appId' : appId,
				'context' : $('#commentary-input').val()
			}, function(data, status) {
				if (status == 'success') {
					if (data.type == 0) {
						alert('成功');
					} else if (data.type == -1) {
						alert(data.msg);
						location.href = 'Login';
					}
				}
			});
		});
		loadCommentarys(page);
	});
</script>
</head>
<body>
	<div class="doc">
		<jsp:include page="widget-head.jsp" />
		<input id="application_id" value="<%=app.getId()%>" type="hidden" />
		<div class="main-context main-context-label">
			<div class="label"><%=app.getName()%></div>
			<div class="main-context">
				<br />
				<iframe name="iframe"
					style="width: 100%; height: 610px; border: none; overflow: hidden;"
					allowfullscreen="true" src="<%=request.getAttribute("IframeUrl")%>"></iframe>
			</div>
		</div>
		<div class="main-context main-context-label">
			<div class="label">介绍</div>
			<div class="main-context"><%=app.getContext()%></div>
		</div>
		<div class="main-context main-context-label">
			<div class="label">评论</div>
			<div id="commentarys" class="main-context"></div>
		</div>
		<div class="main-context main-context-label">
			<div class="label">发表评论</div>
			<div class="commentary main-context">
				<textarea id="commentary-input"
					class="commentary-input height-light-input"></textarea>
				<input id="commentary-send" type="button"
					class="commentary-send height-light-input" value="发送">
			</div>
		</div>
		<jsp:include page="widget-foot.jsp" />
	</div>
</body>
</html>